#!/bin/bash

sudo dpkg-reconfigure locales  # 选择zh_CM.UTF-8 设置中文
sudo apt update
sudo apt install -y build-essential


read -t 10 -p "install nvidia driver? (yes|no): " nvidia

if [ -z $nvidia ] || [ $nvidia == "y" ] || [ $nvidia == "yes" ]; then
    # 禁用nouveau驱动
    sudo bash -c "echo blacklist nouveau > /etc/modprobe.d/nvidia-installer-disable-nouveau.conf"
    sudo bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/nvidia-installer-disable-nouveau.conf"
    
    sudo update-initramfs -u

    cp ./install-nvidia-driver.sh ~/
    sed -i '$ a bash ~\/install-nvidia-driver.sh' ~/.bashrc #重启系统并在用户登录后继续安装
   
    sudo reboot  # 重新启动
fi
